<!-- eslint-disable vue/no-parsing-error -->
<template>
  <div class="card-container" @click="goToDetail()">
    <div class="card-container-header">
      <div class="serial-number">{{ props.cardData.deviceId }}</div>
      <div>{{ props.cardData.bedId }} / {{ props.cardData.patientName }} / {{ props.cardData.gender === 1 ? '男': '女' }} / {{ props.cardData.age }}岁</div>
      <Electric :deviceId="props.cardData.deviceId"/>
    </div>
    <div class="card-container-content">
      <div class="card-container-content-left">
        <div class="card-container-content-chart">
          <EcgChart 
            ref="ecgChartRef"
            height="2cm"
            :width="19"
            :grid="{
              left: '0',right:'0', top:'-10', height: '200%'
            }"
            :deviceId="props.cardData.deviceId"
            :loading="false"
          />
        </div>
        <div class="card-container-content-info">
          <div class="content-info left-info-1"><InfoItem type="resp" :deviceId="props.cardData.deviceId"/>/min</div>
          <div class="content-info left-info-2"><InfoItem type="nibp" :deviceId="props.cardData.deviceId"/>mmhg</div>
        </div>
      </div>
      <div class="card-container-content-right">
        <div class="content-info right-info-1">
          <div><InfoItem type="hr" :deviceId="props.cardData.deviceId"/>bpm</div>
        </div>
        <div class="content-info right-info-2">
          <div><InfoItem type="spo2" :deviceId="props.cardData.deviceId"/>%</div>
        </div>
        <div class="content-info right-info-3">
          <div><InfoItem type="temp" :deviceId="props.cardData.deviceId"/>&#8451</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
// import CommonChart from '@/components/echarts/index.vue'
import EcgChart from '@/components/ecg-chart.vue'
import { useRouter} from 'vue-router'
import {useEquipmentInfoStore} from '@/stores/equipment-info-store'
import InfoItem from '@/components/info-item.vue'
import Electric from '@/components/electric.vue'
const props = defineProps({
  cardData: {
    type: Object,
    default: () => {}
  }
}) as {
  cardData: {
    deviceId: String,
    bedId: String,
    patientName: String,
    gender: Number,
    age: Number
  }
}
// const {RespNode}  = itemRender(props.cardData.deviceId)
const router = useRouter()
const goToDetail = () => {
  router.push({path: '/case-detail', query: {id: props.cardData.deviceId}})
}
const store = useEquipmentInfoStore()


</script>
<style lang="less" scoped>
.card-container {
  color: #fff;
  border: 1px solid rgb(64 129 191);
  border-radius: 3px;
  background-color: rgb(41 51 76);
  cursor: pointer;
  .card-container-header {
    padding: 8px 12px;
    border-bottom: 1px solid rgb(57 81 114);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 20px;
    font-weight: 600;
    height: 50px;
    // .serial-number {
    //   // width: 200px
    // }
    .electric {
      display: flex;
      align-items: center;
      .electric-tip {
        border-radius: 3px;
        margin-right: 5px;
        padding: 8px 12px;
        background-color: rgb(139 54 68);
        font-size: 12px;
      }
    }
    .electric-container {
      position: relative;
      width: 40px;
      border: 1px solid #d2d2d2;
      border-radius: 3px;
      height: 20px;
      .electric-last {
        margin: 3px;
        height: 14px;
        
      }
      .electric-text {
        position: absolute;
        color: #fff;
        font-size: 12px;
        left: 50%;
        transform: translateX(-50%);
      }
    }
    .electric-container::after {
      position: absolute;
      content: '';
      width:2px;
      height: 6px;
      background-color: #d2d2d2;
      right:-2px;
      top: 6px;
    }
  }
  .card-container-content {
    display: flex;
    .card-container-content-left {
      flex: 1;
      border-right: 1px solid rgb(57 81 114);
      
    }
    .card-container-content-chart {
      position: relative;
      height: 3cm;
      border-bottom: 1px solid rgb(57 81 114);
      display: flex;
      align-items: center;
      padding: 8px 16px;
      justify-content: center;
      .empty-line {
        width: 100%;
        height: 1px;
        background-color: rgb(10 210 96);
      }
    }
    .card-container-content-info {
      display: flex;
      align-items: center;
      .left-info-1 {
        width: 30%;
        border-right: 1px solid rgb(57 81 114);
        color: rgb(255 195 0);
      }
      .left-info-2 {
        flex: 1;
      }
    }
    .card-container-content-right {
      width: 20%;
      .right-info-1, .right-info-2 {
        border-bottom: 1px solid rgb(57 81 114);
      }
      .right-info-1, .right-info-2, .right-info-3  {
        div {
          width: 90px;
        }
      }
      .right-info-1 {
        color: rgb(3 255 103);
      }
      .right-info-2 {
        color: rgb(1 95 255);
      }
      .right-info-3 {
        color: rgb(3 255 237);
      }
    }
    
    .content-info {
      height: 1.5cm;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      span {
        font-size: 20px;
        font-weight: 600;
        margin-right: 8px;
      }
    }

  }
}
</style>
